package com.cskaoyan.day03.generic1;

import com.cskaoyan.day03.generic2.MysteryBox;

/**
 * @author stone
 * @date 2022/01/29 09:46
 */
public class GenericDemo1 {

    public static void main(String[] args) {
        //MyLinkedList myLinkedList = new MyLinkedList();
        //myLinkedList.add("红");
        //myLinkedList.add("橙");
        //myLinkedList.add(new Integer(5));

        //想要一个list向里面放Integer类型的值
        MyLinkedList<Integer> list = new MyLinkedList<Integer>();
        //list.add(5);
        list.add(5);
        //list.add("红");
        list.add(10);
        //list.add("橙");

        //显性的类型转换
        //Integer o = (Integer) list.get(0);
        //Integer o1 = (Integer) list.get(1);//红 → Integer

        //使用泛型之后没有做类型转换了，自动转换成对应类型 → 隐性的类型转换
        Integer integer = list.get(0);

        MyLinkedList<String> list2 = new MyLinkedList<String>();
        list2.add("红");

        String s = list2.get(0);

        //MysteryBox<Integer> mysteryBox = new MysteryBox<Integer>();
        // mysteryBox.remove(
        MyLinkedList<Integer> myLinkedList = new MyLinkedList<Integer>();
        myLinkedList.remove(0);
        myLinkedList.remove(new Integer(0));

        MyLinkedList<String> stringMyLinkedList = new MyLinkedList<>();
    }
}
